class Solution
{
public:
    vector<int> arrayRankTransform(vector<int> &arr)
    {
        set<int> s(arr.begin(), arr.end());
        unordered_map<int, int> numRanks;
        int rank = 1;
        for (int num : s)
        {
            numRanks[num] = rank;
            ++rank;
        }
        for (auto &num : arr)
        {
            num = numRanks[num];
        }
        return arr;
    }
};